/** update by jun on 15.8.25 ..*/

var AV = require('leanengine');

//操作产品分类的模型信息
var Classify = AV.Object.extend("Classify");

module.exports = {
    //根据objectId查询单条信息的接口
    get:function(objectId){
        if(objectId){
            var query = new AV.Query(Classify);
            //作为一个promise返回到控制器层面
            return query.get(objectId);
        }else{
            return new AV.Promise.error("objectId should not be empty!");
        }
    },
    //根据分类的名称简码来获取分类
    getByName:function(classifyName){
        if(classifyName) {
            var query = new AV.Query(Classify);
            query.equalTo('gjz', classifyName);
            return query.first();
        }else{
            return new AV.Promise.error("classifyName should not be empty!");
        }
    },
    //查询所有可以展现的分类信息：有些分类是对分类页面隐藏的
    listVisible:function(){
        var query = new AV.Query(Classify);
        query.equalTo('isshow',"1");
        query.equalTo('status',"1");
        query.descending('updateAt');
        return query.find();
    },
};


